package com.qujia.fleet.controller;
import com.qujia.fleet.domain.FleetSubcard;
import com.qujia.fleet.service.FleetSubcardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * @Auther: LogicQin
 * @Date: 2023/5/10 18:53
 * @Description:
 */
@RestController
@RequestMapping("/fleetSubcards")
@Api(tags = "FleetSubcardController", description = "车队子卡管理")
public class FleetSubcardController {

    private final FleetSubcardService fleetSubcardService;

    @Autowired
    public FleetSubcardController(FleetSubcardService fleetSubcardService) {
        this.fleetSubcardService = fleetSubcardService;
    }

    /**
     * 根据ID获取车队子卡信息
     */
    @GetMapping("/{id}")
    @ApiOperation("根据ID获取车队子卡信息")
    public FleetSubcard getFleetSubcardById(@PathVariable Integer id) {
        return fleetSubcardService.getFleetSubcardById(id);
    }

    /**
     * 获取所有车队子卡信息
     */
    @GetMapping("/all")
    @ApiOperation("获取所有车队子卡信息")
    public List<FleetSubcard> getAllFleetSubcards() {
        return fleetSubcardService.getAllFleetSubcards();
    }

    /**
     * 创建车队子卡
     */
    @PostMapping("/create")
    @ApiOperation("创建车队子卡")
    public void createFleetSubcard(@RequestBody FleetSubcard fleetSubcard) {
        fleetSubcardService.createFleetSubcard(fleetSubcard);
    }

    /**
     * 更新车队子卡信息
     */
    @PutMapping("/update")
    @ApiOperation("更新车队子卡信息")
    public void updateFleetSubcard(@RequestBody FleetSubcard fleetSubcard) {
        fleetSubcardService.updateFleetSubcard(fleetSubcard);
    }

    /**
     * 根据ID删除车队子卡
     */
    @DeleteMapping("/{id}")
    @ApiOperation("根据ID删除车队子卡")
    public void deleteFleetSubcardById(@PathVariable Integer id) {
        fleetSubcardService.deleteFleetSubcardById(id);
    }

    /**
     * 批量删除车队子卡
     */
    @DeleteMapping("/batchDelete")
    @ApiOperation("批量删除车队子卡")
    public void deleteFleetSubcardsByIds(@RequestBody List<Integer> ids) {
        fleetSubcardService.deleteFleetSubcardsByIds(ids);
    }
}


